package view.mediator
{
	import controllers.commands.StartPositionCommand;
	
	import model.context.TrackerContext;
	import model.filter.MapFilter;
	import model.registry.EnvConst;
	
	import mx.core.UIComponent;
	import mx.utils.ArrayUtil;
	
	import view.MapCanvas;

	public class PlaybackMediator
	{
		private var container:MapCanvas;
		public var playbackCMD : StartPositionCommand = new StartPositionCommand();
		private var positionArray : Array = null;
		public function PlaybackMediator(c:MapCanvas)
		{
			container = c;
		}
		
		public function setData(data:Object):void
		{
			positionArray = ArrayUtil.toArray(data);
		}
		
		public function setView(view:UIComponent):void
		{
		
		}
		
		public function start():void
		{
			var context : TrackerContext = new TrackerContext();
			context.workType = EnvConst.TYPE_LOCATION_DATA;
			context.mapCanvas = this.container;	
			positionArray = MapFilter.updateArray(positionArray);
			var totalPosInfo:Object = {};
			totalPosInfo.map = positionArray; 
			totalPosInfo.sat = positionArray;
			context.totalPos = totalPosInfo;
			playbackCMD.setContext(context);
			playbackCMD.execute();
		}
	}
}